package com.example
//函数的参数是另外一个函数

fun main() {
    /*val showPrintLn = { goodsName: String, hour: Int ->
            val currentYear = 2027
            "${currentYear}年，双十一${goodsName}促销倒计时: ${hour}小时"
    }
    showOnBoard2("华为手机",showPrintLn)*/

    //当lambda参数为最后一个参数或者为唯一参数时，可以省略圆括号
    showOnBoard2("华为手机"){ goodsName: String, hour: Int ->
        val currentYear = 2027
        "${currentYear}年，双十一${goodsName}促销倒计时: ${hour}小时"
    }
}


private fun showOnBoard2(goodsName:String,showDiscount:(String,Int)->String) {
    val hour = (1..24).shuffled().last()
    println(showDiscount(goodsName,hour))
}